package flc.ast;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.HotFragment;
import flc.ast.fragment.MessageFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.RankFragment;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        mDataBinding.llHomeBottom.setOnClickListener(null);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(RankFragment.class, R.id.llRank));
        listFragment.add(new FragmentViewBinder(MessageFragment.class, R.id.llMessage));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.sy);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#027EFA"));
                break;
            case R.id.llRank:
                mDataBinding.ivRank.setImageResource(R.drawable.ph);
                mDataBinding.tvRank.setTextColor(Color.parseColor("#027EFA"));
                break;
            case R.id.llMessage:
                mDataBinding.ivMessage.setImageResource(R.drawable.fx);
                mDataBinding.tvMessage.setTextColor(Color.parseColor("#027EFA"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.wd);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#027EFA"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.syw);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#727E96"));
        mDataBinding.ivRank.setImageResource(R.drawable.phw);
        mDataBinding.tvRank.setTextColor(Color.parseColor("#727E96"));
        mDataBinding.ivMessage.setImageResource(R.drawable.fxw);
        mDataBinding.tvMessage.setTextColor(Color.parseColor("#727E96"));
        mDataBinding.ivMy.setImageResource(R.drawable.wdw);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#727E96"));
    }

}